package main

import "fmt"

var quit chan int // 只开一个信道

func foo123(id int) {
	fmt.Println("id ", id)
	quit <- id // ok, finished
}

func main() {
	count := 10
	quit = make(chan int, count) // 无缓冲

	for i := 0; i < count; i++ {
		go foo123(i)
	}

	for i := 0; i < count; i++ {
		fmt.Printf("quit %d ", <-quit)
	}
}
